<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<!--{hook admin_comment_start.htm}-->
<div class="container-fluid px-0">
<div class="row">
    <div class="col-lg-12">
        <!--{hook admin_comment_breadcrumb_before.htm}-->
        <?php if(empty($hide_breadcrumb)) { ?>
        <ol class="breadcrumb d-none d-md-flex text-muted">
            <li class="breadcrumb-item"><a href="./"><i class="icon-home" aria-hidden="true"></i></a></li>
            <li class="breadcrumb-item"><?php echo lang('comment');?></li>
            <li class="breadcrumb-item"><?php echo lang('list');?></li>
            <!--{hook admin_comment_breadcrumb.htm}-->
        </ol>
        <?php } ?>
        <!--{hook admin_comment_breadcrumb_after.htm}-->

        <!--{hook admin_comment_before.htm}-->
        <div class="card card-threadlist">
            <div class="card-body">
                <ul class="list-unstyled threadlist mb-0">
                    <!--{hook admin_comment_threadlist_before.htm}-->
                    <?php if(!empty($postlist)) { foreach($postlist as $_post) { ?>
                    <li class="media <?php echo $_post['classname'];?>" data-pid="<?php echo $_post['pid'];?>" data-uid="<?php echo $_post['uid'];?>">
                        <?php if($_post['allowdelete']) { ?>
                        <input type="checkbox" name="pid" class="mt-3 mr-2" value="<?php echo $_post['pid']; ?>" />
                        <?php } ?>
                        <!--{hook reply_list_inc_avatar_after.htm}-->
                        <div class="media-body">
                            <div class="d-flex justify-content-between small text-muted">
                                <div>
                                    <!--{hook admin_comment_list_inc_avatar_before.htm}-->
                                    <a href="<?php echo url('user-' . $_post['uid']);?>" rel="nofollow" tabindex="-1" class="mr-2">
                                        <img class="avatar-1" src="<?php echo $_post['user_avatar_url'];?>">
                                    </a>
                                    <!--{hook admin_comment_list_inc_username_before.htm}-->
                                    <span class="username">
                                                <a href="<?php echo url('user-' . $_post['uid']);?>" class="text-muted font-weight-bold"><?php echo $_post['username'];?></a>
                                            </span>
                                    <!--{hook admin_comment_list_inc_username_after.htm}-->

                                    <!--{hook admin_comment_list_inc_create_date_before.htm}-->
                                    <span class="date text-grey ml-2"><?php echo $_post['create_date_fmt'];?></span>
                                    <!--{hook admin_comment_list_inc_create_date_after.htm}-->
                                </div>
                                <div class="text-right text-grey">

                                    <!--{hook admin_comment_list_inc_update_before.htm}-->
                                    <?php if($_post['allowupdate']) { ?>
                                    <!--<a href="<?php echo url('comment-update-'.$_post['pid']);?>" class="text-grey post_update mr-3"><i class="icon-edit" title="<?php echo lang('edit');?>"></i> <span class="d-none"><?php echo lang('edit');?></span></a>-->
                                    <?php } ?>
                                    <!--{hook admin_comment_list_inc_update_after.htm}-->

                                    <!--{hook admin_comment_list_inc_delete_before.htm}-->
                                    <?php if($_post['allowdelete']) { ?>
                                    <a data-href="<?php echo url_path().url('comment-delete-'.$_post['pid']);?>" data-confirm-text="<?php echo lang('confirm_delete');?>" href="javascript:void(0);" class="text-grey post_delete _confirm mr-3"><i class="icon-remove" title="<?php echo lang('delete');?>"></i> <span class="d-none"><?php echo lang('delete');?></span></a>
                                    <?php } ?>
                                    <!--{hook admin_comment_list_inc_delete_after.htm}-->

                                </div>
                            </div>
                            <div class="message mt-1 break-all">

                                <!--{hook admin_comment_list_inc_subject_before.htm}-->
                                <?php if($route != 'read' && !empty($_post['subject'])) { ?>
                                <h6><a href="<?php echo url('read-' . $_post['tid']);?>" target="_blank"><?php echo $_post['subject'];?></a></h6>
                                <?php } ?>
                                <!--{hook admin_comment_list_inc_subject_after.htm}-->

                                <!--{hook admin_comment_list_inc_message_before.htm}-->
                                <?php echo $_post['message'];?>
                                <!--{hook admin_comment_list_inc_message_after.htm}-->

                            </div>
                        </div>
                    </li>
                    <?php }} ?>

                    <!--{hook admin_comment_threadlist_after.htm}-->
                </ul>
            </div>
        </div>

        <?php if(group_access($gid, 'managedeletethread')) { ?>
        <div class="text-center">
            <label class="mr-3">
                <input type="checkbox" data-target='input[name="pid"]' class="checkall mt-2 mr-2" value="" aria-label="<?php echo lang('checkall');?>" /><?php echo lang('checkall');?>
            </label>
            <div class="btn-group mod-button my-3" role="group" aria-label="">
                <!--{hook admin_comment_mode_delete_before.htm}-->
                <button class="btn btn-secondary delete" data-href="<?php echo url_path().url('comment-delete');?>"><?php echo lang('delete');?></button>
                <!--{hook admin_comment_mode_delete_after.htm}-->
            </div>
        </div>
        <?php } ?>

        <!--{hook admin_comment_page_before.htm}-->
        <?php if ($pagination) { ?>
        <nav class="my-3"><ul class="pagination justify-content-center flex-wrap"><?php echo $pagination; ?></ul></nav>
        <?php } ?>
        <!--{hook admin_comment_page_after.htm}-->
    </div>
</div>
</div>
<!--{hook admin_comment_end.htm}-->

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<script>
    $('.threadlist').base_href('<?php echo url_path();?>');
    var safe_token = '<?php echo $safe_token;?>';
    var body = $('body');
    body.on('click', 'button.delete', function() {
        var jthis = $(this);
        var pidarr = $('input[name="pid"]').checked();
        var href = jthis.data('href');
        if (window.confirm(lang.confirm_delete)) {
            $.xpost(href, {type:1,pid:pidarr,safe_token: safe_token}, function(code, message) {
                if(code == 0) {
                    window.location.reload();
                } else {
                    $.alert(message);
                }
            });
        }
        return false;
    });

    $('input[name="post_verify"]').click(function () {
        if ($(this).checked() == 1) {
            window.location = xn.url('comment-list-1')+'?verify=<?php echo $verify;?>';
        } else {
            window.location = xn.url('comment-list');
        }
    });

    $('#content').addClass('show');
    $('.sidebar-sticky li.menu-comment').addClass('active').prepend('<div class="arrow-tips float-right d-none d-md-block"></div>');
</script>

<!--{hook admin_comment_js.htm}-->